
var accessories=new Vue({
    el:'#accessories',
    data:()=>({
        listdata:[],
        page:1,
        sousuo:'',
        lang:"",
        pro_id:1,
        prochar:[],
        prochar_id:0
    }),
    methods:{
        formatUnit:formatUnit,
        getitemdata(){
            $.ajax({
                url:'/admin/product/proAddNewJump?request=item&requestType=isAjax&pro_id='+$('#pro_id').val(),
                data: {
                    page: this.page,
                    limit: 2,
                    lang: this.lang,
                    prochar_id:this.prochar_id
                },
                type:'post',
                success:(data)=>{
                    data = JSON.parse(data)
                    console.log(123)
                    this.pro_id = data.pro_id
                    this.prochar = data.procharlist                  
                    this.listdata = data.itemSet
                    if(data.size)
                    this.setPage(1,Math.ceil(data.size /2))
                }
            })
        },
        changeprochar(){
            this.prochar_id = $('#prochar option:selected').val()
            this.getdata();
        },
        itemChangeStatus(id){
            $.ajax({
                url:'/admin/product/proAddNewJump_itemDel',
                data: {
                    id:id
                },
                type:'post',
                success:(data)=>{
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert',data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+data.msg+'<br>')
                    } else {
                        change_mes_type('.alert',data.status)
                        $('.alert').show()
                        $('.alert p').html('*'+data.msg+'<br>')
                        this.getdata()
                    }
                }
            })
        }

    },
    mounted(){
        this.getdata()
        $('#pro2item_editModal').on('hidden.bs.modal',(e)=>{
            this.getdata()
          })
        $('#proitem_newModal').on('hidden.bs.modal',(e)=>{
            this.getdata()
          })
    },
    watch:{
        lang:function(){
            this.getdata()
        }
    }
})